﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Net.TheBoredCoders.SoundBoard.Controls
{
    public partial class BaseButtonPanel : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseButtonPanel"/> class.
        /// </summary>
        public BaseButtonPanel()
        {
            InitializeComponent();
        }

        [Obsolete("Can be removed after new Data-Object is implemented...")]
        public BaseButtonPanel(String folderPath)
            :this()
        {
            if (String.IsNullOrEmpty(folderPath))
            {
                this.Dispose();
                return;
            }

            this.Name = System.IO.Path.GetDirectoryName(folderPath);
            String[] files = System.IO.Directory.GetFiles(folderPath);

            foreach (String file in files) // check all files in directory
            {
                if (System.IO.Path.GetExtension(file).ToLower() == ".wav") // if filetype matches (.wav)
                {
                    this.flowPanel.Controls.Add(HelperClass.CreateSoundBoardButton(file,ref toolTip)); // create button
                }
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseButtonPanel"/> class.
        /// </summary>
        /// <param name="samples">The samples that should be used for the buttons in the panel.</param>
        public BaseButtonPanel(List<SampleData> samples)
            : this()
        {
            foreach (SampleData sample in samples)
            {
                this.flowPanel.Controls.Add(HelperClass.CreateSoundBoardButton(sample, ref toolTip)); // create button
            }
        }


    }
}
